home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Window / c / Create < prev    next >
Text File  |  1995-07-08  |  2KB  |  66 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Window.Create.c
  12.     Author:  Copyright © 1992, 1993, 1994 Jason Williams
  13.     Version: 1.01 (30 May 1994)
  14.     Purpose: High-level window management functions: Create a window
  15. */
  16.  
  17.  
  18. #include <stdlib.h>
  19. #include <string.h>
  20.  
  21. #include "DeskLib:LinkList.h"
  22. #include "DeskLib:WimpSWIs.h"
  23. #include "DeskLib:Template.h"
  24. #include "DeskLib:Event.h"
  25. #include "DeskLib:Window.h"
  26. #include "DeskLib:Screen.h"
  27. #include "DeskLib:Error.h"
  28.  
  29. #include "WindowDefs.h"
  30.  
  31.  
  32. #define ERRBASE 1
  33. #define ERR1 ERRBASE+0
  34. #define ERRMESS1 "Insufficient memory to open window"
  35.  
  36.  
  37. linklist_header window_listanchor;
  38.  
  39.  
  40. extern window_handle Window_Create(char *windowname, int maxtitlesize)
  41. {
  42.   windowrec     *record;
  43.   window_block  *windowptr;
  44.   window_handle window;
  45.  
  46.   windowptr = Template_Clone(windowname, maxtitlesize);
  47.   if (windowptr == NULL)
  48.     return(0);
  49.  
  50.   Wimp_CreateWindow(windowptr, &window);
  51.  
  52.   record = (windowrec *) malloc(sizeof(windowrec));
  53.   if (record == NULL)  Error_ReportFatalInternal(ERR1, ERRMESS1);
  54.  
  55.   LinkList_AddToHead(&window_listanchor, &(record->header));
  56.  
  57.   strncpy(record->templatename, windowname, wimp_MAXNAME);
  58.   record->templatename[wimp_MAXNAME] = 0;       /* Record of name for help   */
  59.  
  60.   record->window = window;                      /* Remember window handle    */
  61.   record->memory = windowptr;                   /* remember to dealloc later */
  62.  
  63.   return(window);
  64. }
  65.  
  66.